<?php
class HDataPager {
	function render($table, $size, $current_page, $page_alias, $sqlcondition = null) {		
		$a = HSql::fetch2Array(HSql::getData($table, $sqlcondition));
		$total = round((count($a) / $size) + 1);			
		?>
		<div class="pagination">
			<?php if ($current_page >= 2) {?>
			<a href="<?php echo HCommon::navigateUrl($page_alias, array('page'=>'1'));?>" title="First Page">&laquo; First</a>
			<a href="<?php echo HCommon::navigateUrl($page_alias, array('page'=>($current_page - 1)));?>" title="Previous Page">&laquo; Previous</a>
			<?php } ?>
			
			<!-- Pager item -->
			<?php
			for ($i = 0; $i < $total; $i++) {
				if (($current_page - 1) == $i) {
				?>
				<a href="<?php echo HCommon::navigateUrl($page_alias, array('page'=>$i + 1));?>" class="number current" title="<?php echo $i + 1;?>">
					<?php echo $i + 1;?></a
				<?php } else { ?>
				<a href="<?php echo HCommon::navigateUrl($page_alias, array('page'=>$i + 1));?>" class="number" title="<?php echo $i + 1;?>">
					<?php echo $i + 1;?></a>				
				<?php
				}
			}
			?>
			
			<?php if ($current_page >= 2) {?>
			<a href="<?php echo HCommon::navigateUrl($page_alias, array('page'=>($current_page + 1)));?>" title="Next Page">Next &raquo;</a>
			<a href="<?php echo HCommon::navigateUrl($page_alias, array('page'=>$total));?>" title="Last Page">Last &raquo;</a>
			<?php } ?>
		</div> <!-- End .pagination -->		
		<?php 		
	}
}
?>